package com.baiyjk.droolsengine.backser.entity.search;

import java.util.ArrayList;
import java.util.List;

public class PageItem<T> {
	private int pageNo = 1; // 当前第几页
	private int itemNo=0;
	private int count = 0; // 总共条数
	private int pageSize = 10; // 每页显示多少条
	private int pageSum = 1; // 总共页数
	private List<T> data = null; // 当前页数据
	public int getPageNo() {
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
		if (this.pageNo <= 1) {
			this.pageNo = 1;
		} else {
			if (this.count != 0) {
				if (this.pageNo >= pageSum) {
					this.pageNo = pageSum;
				}
			}
		}
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
		if (this.count <= pageSize) {
			this.pageSum = 1;
			this.pageNo = 1;
		} else {
			if (this.count % this.pageSize == 0) {
				this.pageSum = this.count / this.pageSize;
			} else {
				this.pageSum = this.count / this.pageSize + 1;
			}
		}
		this.setPageNo(this.pageNo);
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageSum() {
		return pageSum;
	}
	public void setPageSum(int pageSum) {
		this.pageSum = pageSum;
	}
	public List<T> getData() {
		return data;
	}
	public void setList(List<T> list) {
		if(list == null){
			list = new ArrayList<T>();
		}
		this.data = list;
	}
	public int getItemNo() {
		return (pageNo-1)*pageSize;
	}
	public void setItemNo() {
		this.itemNo = (pageNo-1)*pageSize;
	}
	public void setData(List<T> data) {
		this.data = data;
	}
	
}
